Skip to content

ProviderManager should have a varargs constructor #7806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2020
Merged

ProviderManager should have a varargs constructor #7806

merged 2 commits into from
Jan 30, 2020

Conversation

ThomasVitale
Copy link
Contributor

  • Added varargs constructor to ProviderManager.
  • Updated ProviderManagerTests to use the new syntax and fix the check for empty list.

Fixes gh-7713

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 10, 2020
Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @ThomasVitale! I've left some feedback inline.

@@ -96,7 +94,7 @@ public void authenticationSucceedsWhenFirstProviderReturnsNullButSecondAuthentic

@Test(expected = IllegalArgumentException.class)
public void testStartupFailsIfProvidersNotSet() {
new ProviderManager(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should still have a test for new ProviderManager((AuthenticationProvider) null) and for new ProviderManager((List<AuthenticationProvider>) null).

The reason is that an application might do:

AuthenticationProvider provider = constructProvider();
return new ProviderManager(provider);

but constructProvider returns null.

I believe this also implies that the extra validation logic in checkState() will turn out to be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for the clarification. I have added the extra validation login in checkState() and tests for both null scenarios.

@@ -189,7 +186,7 @@ public void parentAuthenticationIsUsedIfProvidersDontAuthenticate() {
Authentication authReq = mock(Authentication.class);
when(parent.authenticate(authReq)).thenReturn(authReq);
ProviderManager mgr = new ProviderManager(
Arrays.asList(mock(AuthenticationProvider.class)), parent);
Collections.singletonList(mock(AuthenticationProvider.class)), parent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these cleanup items, too. Will you please put them in a separate commit (same PR)? That is, any code changes that aren't directly related to the new constructor, let's separate them into their own commit. This simplifies maintenance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now they are in their own commit.

@jzheaux jzheaux self-assigned this Jan 14, 2020
@jzheaux jzheaux added in: core An issue in spring-security-core type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 14, 2020
@jzheaux jzheaux added this to the 5.3.0.RC1 milestone Jan 14, 2020
@jzheaux
Copy link
Contributor

jzheaux commented Jan 29, 2020

@ThomasVitale Will you be able to apply the requested changes?

@ThomasVitale
Copy link
Contributor Author

@jzheaux I have just delivered the requested changes, sorry for the delay. Does it look ok now?

- Added varargs constructor to ProviderManager.
- Added check for null values in AuthenticationProvider list.
- Updated ProviderManagerTests to test for null values using both constructors.

Fixes gh-7713
@jzheaux jzheaux merged commit ace89e1 into spring-projects:master Jan 30, 2020
@jzheaux
Copy link
Contributor

jzheaux commented Jan 30, 2020

Nice, @ThomasVitale! This is now merged into master.

Also, I added a very slight polish via d22b476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProviderManager should have a varargs constructor
3 participants